<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <div class="contentsize">档案管理-档案查询</div>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <!-- <el-form ref="form" :model="form" label-width="auto" :inline="true" size="mini">
                    <el-form-item label="档案编号:">
                        <div style="width:170px">
                            <el-input v-model="form.dabh" placeholder="请输入档案编号"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="房屋地址:">
                        <div style="width:170px">
                            <el-input v-model="form.dz" placeholder="请输入房屋地址"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="所属事务:">
                        <div style="width:170px">
                            <el-select v-model="form.sssw" placeholder="请选择所属事务">
                                <el-option v-for="item in ssswlist" :key="item.code" :label="item.name" :value="item.code">
                                </el-option>
                            </el-select>
                        </div>
                    </el-form-item>
                    <el-form-item label="是否完结:">
                        <div style="width:170px">
                            <el-select v-model="form.zt" placeholder="请选择是否完结">
                                <el-option v-for="item in ztlist" :key="item.code" :label="item.name" :value="item.code">
                                </el-option>
                            </el-select>
                        </div>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSearch" icon="el-icon-search" class="searchcolor">查询</el-button>
                    </el-form-item>
                </el-form> -->
            </div>
            <el-table :data="tableDatabj" style="width: 100%" :header-cell-style="tableHeaderColor" :row-style="tablerowColor" border>
                <el-table-column prop="dabh" label="档案编号" align="center"> </el-table-column>
                <el-table-column prop="dz" label="地址" align="center"> </el-table-column>
                <el-table-column prop="addusername" label="发起人" align="center"> </el-table-column>
                <el-table-column prop="sssw" label="所属事务" align="center"> </el-table-column>
                <el-table-column label="操作" width="100" align="center">
                    <template slot-scope="scope">
                        <el-button type="text" size="small" @click="gotofwjg(scope.row.processcode, scope.row.id)">详情</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination" style="float: right">
                <el-pagination
                    background
                    layout="total,prev, pager, next,jumper"
                    :total="totalbj"
                    :current-page.sync="currentbj"
                    :page-size="pageSize"
                    @current-change="handleCurrentChangebj"
                >
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import { gdcaselist, dbnodelete } from '@/api/index';
import valueList from '@/components/common/valueList.vue';
export default {
    name: 'gdlistbj',
    data() {
        return {
            ssswlist: valueList.ssswlist, //所属事物列表
            pageSize: 10,
            totalbj: 0,
            currentbj: 1,
            formbj: {
                adduser: this.$store.getters.userId,
                caseid: '', //流程实例id,
                create_name: '', //创建人,
                create_name_id: '', //创建人id,
                create_time: '', //创建时间,
                current: 1, // 第几页 ,
                fj: '', //归档附件 ,
                gdjl: '', //归档记录 ,
                id: '', //id ,
                pageSize: 10, // 每页数量 ,
                status_code: 1, // 1正常 2删除 ,
                update_name: '', //修改人 ,
                update_name_id: '', //修改人id ,
                update_time: '', //修改时间 ,
                zt: 1 //归档状态 0：待办 1：已办
            },
            tableDatabj: [],
            ztlist: [
                { name: '是', code: 1 },
                { name: '否', code: 0 }
            ]
        };
    },
    components: {},
    computed: {},
    methods: {
        // 列表样式
        tableHeaderColor({ row, column, rowIndex, columnIndex }) {
            if (rowIndex === 0) {
                return 'background-color: #f7f7f7;color:black;height: 54px;font-weight: 500;font-size:14px;font-variant:tabular-nums';
            }
        },
        tablerowColor({ row, rowIndex }) {
            return 'height: 42px;font-size:14px;';
        },
        // 换页办结
        handleCurrentChangebj(val) {
            this.currentbj = val;
            this.formbj.current = val;
            this.gdcaselistbj(this.formbj);
            console.log(val);
        },
        // 搜索
        onSearch() {
            this.current = 1;
            this.form.current = 1;
            this.gdcaselist(this.form);
            console.log('搜索');
        },
        // 办结列表
        gdcaselistbj(data) {
            gdcaselist(data).then((res) => {
                if (res.code == 200) {
                    this.tableDatabj = res.data.records;
                    this.totalbj = res.data.total;
                } else {
                    this.tableDatabj = [];
                    this.totalbj = 0;
                }
            });
        },
        // 跳转流程页面
        gotofwjg(val, id) {
            if (val == 'jlbqtht1' || val == 'jlbqtht2') {
                this.$router.push({
                    // name: val,
                    name: 'qthtgd',
                    params: {
                        id: id
                    }
                });
            } else {
                let firstThree = val.substring(0, 3); // 获取前三个字符
                let rest = val.substring(3); // 获取剩余的字符
                let name = firstThree == 'jlb' ? rest + 'gd' : val + 'gd';
                // let name = val + 'gd'
                this.$router.push({
                    name: name,
                    params: { id: id }
                });
            }
        }
    },
    mounted() {
        console.log(this.$store.getters);
        this.gdcaselistbj(this.formbj);
        console.log(valueList);
    }
};
</script>

<style scoped>
.container {
    overflow: hidden;
}

.crumbs {
    background-color: #fff;
    padding: 20px 20px;
}

.indexTitle {
    margin-bottom: 20px;
}

.contentsize {
    font-size: 18px;
    font-weight: 700;
}

.handle-box {
    overflow: hidden;
}

/* 新增按钮 */
.addcolor {
    margin-bottom: 10px;
}

.unloadTitle {
    text-align: left;
    padding-bottom: 10px;
    box-sizing: border-box;
    color: #606266;
}
</style>
